<?php
namespace app\wap\controller;

use think\facade\Cookie;

class Base extends \app\BaseController
{
	protected $uuid=0;
	protected $token='';
	
	public function initialize(){
		parent::initialize();
		$this->loadJsCss();
		
		// 当前控制器路径（不加action）
		$this->MODULE_PATH=$this->request->root().'/'.MODULE_NAME.'/';

		$this->assign('MODULE_PATH',$this->MODULE_PATH);
		
		// 设置UUID为内置属性
		$this->uuid = I('get.ssid');
		$this->token = I('get.k');
		$this->assign('uuid',$this->uuid);
		$this->assign('token',$this->token);
	}
	// 默认加载的CSS和JS
	protected function loadJsCss(){
		$data=[];
		$load=[
			'top'=>[
				'css'=>[
					env('path.css_path').'/wap/weui.css',
					env('path.css_path').'/wap/weuix.css',
				],
				'js'=>[
					env('path.js_path').'/jquery.1.8.3.js',
				]
			],
			'bottom'=>[
				
			]
		];
		foreach($load as $name=>$postion){
			$data[$name]='';
			foreach($postion as $type=>$list){
				foreach($list as $path){
					if($type =='css'){
						$data[$name].='<link rel="stylesheet" href="'.$path.'" />';
					}else if($type == 'js'){
						$data[$name].='<script src="'.$path.'"></script>';
					}
				}
			}
		}
		$this->assign('LOAD_STYLE',$data);
	}
}
